package com.me.test;

import java.util.Scanner;

/**
 * @author Li
 * @Date 2023/4/7 18:10
 */
public class PrintHello {
    public static void main(String[] args) {
        int count = getNum("输入打印次数:");
        String words = getString("输入打印内容");
        printWords(count,words);

    }

    /**
     * 根据获取打印次数和打印内容进行循环打印
     * @param count
     * @param words
     */
    private static void printWords(int count,String words){
    for (int i = 0;i<count;i++){
        System.out.println("第"+(i+1)+"次"+words);
    }
}

    /**
     * 键盘输入打印内容
     * @param tip
     * @return
     */
    private static String getString(String tip) {
   Scanner scanner = new Scanner(System.in);
        System.out.println(tip);
        String str = scanner.next();
        return str;
    }

    /**
     * 键盘输入打印次数
     * @param tp
     * @return
     */
    private static int getNum(String tp) {
        Scanner scanner= new Scanner(System.in);
        System.out.println(tp);
        int num = scanner.nextInt();
        return num;
    }
}
